<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>购物车结算</title>
<%
pageContext.setAttribute("path",request.getContextPath());
%>
<link rel="stylesheet" href="${path}/css/reset.css">
<link rel="stylesheet" href="${path}/css/carts.css">
<link href="../../css/index.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="${path}/js/jquery-3.3.1.min.js"></script>
<script src="${path}/js/carts.js"></script>
</head>
<body id="top">
<div class="jdm-toolbar-wrap J-wrap">                
			<div class="jdm-toolbar J-toolbar">                    
				 <div class="jdm-toolbar-panels J-panel">                                             
				</div>                                       
				<div class="jdm-toolbar-tabs J-tab">  
					<div data-type="bar" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-cart">                                
						<i class="tab-ico"></i>  <a href="${pageContext.request.contextPath}/Carts?userId=${sessionScope.user.userId}">                              <em class="tab-text">购物车                                
						</em>  </a>                                                
					</div>   
					<div class="J-trigger jdm-toolbar-tab jdm-tbar-tab-message" data-name="message"><a target="_blank" href="#">
					<i class="tab-ico"></i>                                
					<em class="tab-text">                                    我的消息                                
					</em></a>                                                
				</div>                     
			</div>                     
			<div class="jdm-toolbar-footer">                        
				<div data-type="link" id="#top" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-top">                                
					<a href="#" clstag="h|keycount|cebianlan_h|top">                                
						<i class="tab-ico"></i>                                <em class="tab-text">顶部</em>                                
					</a>                         
				</div>                        
				<div data-type="link" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-feedback">                                 
					<a href="http://surveys.jd.com/index.php?r=survey/index/sid/889711/newtest/Y/lang/zh-Hans" target="_blank" clstag="h|keycount|cebianlan_h|feedback">                                    
						<i class="tab-ico"></i>                                    
						<em class="tab-text">反馈</em>                                
					</a>                        
				</div>                        
			</div>                    
			<div class="jdm-toolbar-mini">                    
			</div>                
		</div>                
		<div id="J-toolbar-load-hook" clstag="h|keycount|cebianlan_h|load"></div>            
	</div>
		<!-----------------------------------------顶部-------------->
		<header id="header">
			<div class="header-box">
				<ul class="header-left">
				</ul>
				<ul class="header-right">
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/user/userLogin.jsp">您好，请登录</a> <a href="${pageContext.request.contextPath}/jsp/user/userRegister.jsp"  class="red">免费注册</a></li> 
					<li class="shu"></li>
					<li class="denglu"><a href="#">我的订单</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/showFavorite?userId=${sessionScope.user.userId}">我的收藏夹</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/getUsers?userId=${sessionScope.user.userId}">个人中心</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/shop/ShopLogin.jsp">卖家中心</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/login/login.jsp">管理员中心</a></li>
				</ul>
			</div>
		</header>
		<div class="w">
			<div class="logo"><a href="${pageContext.request.contextPath}/index.jsp"><img width="100" height= "80" src="./../../images/logo.png"></a></div>
			<div class="search" id="search">
				<input type="text" placeholder="搜索" class="text" id="textt">
				<button class="button" onclick="find()">搜索</button>
			</div>
			<div class="right">
				<i class="gw-left" style="background:url(./../../images/jd2015img.png)0 -58px no-repeat;width:24px;height:24px;"></i>
				<i class="gw-right">></i>
				<i class="gw-count">0</i>
				<a href="#">我的购物车</a>
				<div class="dorpdown-layer">
					<img src="./../../images/settleup-nogoods.png">
					购物车中还没有商品，赶紧选购吧！
				</div>
			</div>
			<div class="hotwords">
				<a href="#">海苔</a>
				<a href="#">果冻</a>
				<a href="#">饼干</a>
				<a href="#">锅巴</a>
				<a href="#">可乐</a>
			</div>
		</div>
		
		<div class="clear"></div>
		<!--轮播图上方导航栏  一栏-->
		<div id="navv">
		</div>
		<div class="focus">
			<div class="focus-a">
				<!-- <div class="fouc-img1"><img src="./../../images/5689d4ebN19f155a6.jpg" class="nav-img2"></div>
				<div class="fouc-font"><a href="">全部商品分类</a> </div> -->
			</div>
			<div class="focus-b">
				<ul>
					<li><a href="${pageContext.request.contextPath}/index.jsp">首页</a></li>
					<li><a href="#" onclick="showGoods(0)">坚果炒货</a></li>
					<li><a href="#" onclick="showGoods(1)">饼干蛋糕</a></li>
					<li><a href="#" onclick="showGoods(2)">糖果巧克力</a></li>
					<li><a href="#" onclick="showGoods(3)">肉类制品</a></li>
					<li><a href="#" onclick="showGoods(4)">膨化食品</a></li>
					<li><a href="#" onclick="showGoods(5)">饮料牛奶</a></li>
				</ul>
			</div>
   <section class="cartMain">
	<div class="cartMain_hd">
		<ul class="order_lists cartTop">
			<li class="list_chk">
				<!--所有商品全选-->
				<input type="checkbox" id="all" class="whole_check">
				<label for="all"></label>
				全选
			</li>
			<li class="list_con">商品信息</li>
			<li class="list_info">口味</li>
			<li class="list_price">单价</li>
			<li class="list_amount">数量</li>
			<li class="list_sum">金额</li>
			<li class="list_op">操作</li>
		</ul>
	</div>
	
    
	<div class="cartBox">
	
		<%-- <c:forEach items="${cartshop}" var="cartshops"> --%>
		
	  <div>
		<c:forEach items="${carts}" var="cart">
		
		<%-- <c:if test="${cartshop.shopId==cart.shopId}"> --%>
		<div class="order_content">
			<ul class="order_lists">
				<li class="list_chk">
					<input type="checkbox" id="${cart.goodsId }" class="son_check">
					<label for="${cart.goodsId }"></label>
				</li>
				<li class="list_con">
					<div class="list_img"><a href="javascript:;"><img src="${path}/images/${cart.goodsPhoto}" alt=""></a></div>
					<div class="list_text"><a href="javascript:;">${cart.goodsName }</a></div>
				</li>
				<li class="list_info">
					<p>${cart.goodsTaste}</p>
				</li>
				<li class="list_price">
					<p class="price">￥${cart.goodsPrice}</p>
				</li>
				<li class="list_amount">
					<div class="amount_box">
					   <a href="javascript:;" class="reduce reSty">-</a>
						<input type="text" itemPrice="${cart.goodsPrice}" itemId="${cart.goodsId }" value="${cart.cartNum}" class="sum">
					   <a href="javascript:;" class="plus">+</a>
						
					</div>
				</li>
				<li class="list_sum">
					<p class="sum_price">￥${cart.cartNum*cart.goodsPrice}</p>
				</li>
				<li class="list_op">
					<p class="del"><a href="javascript:;" onclick="goDelete(${cart.cartId})" class="delBtn">移除商品</a></p>
				</li>
			</ul>	
		</div>
		
	<%-- 	</c:if> --%>
	   
		</c:forEach>
	</div>
	<%-- </c:forEach> --%>
	</div>
	<!--底部-->
	<div class="bar-wrapper">
		<div class="bar-right">
			<div class="piece">已选商品<strong class="piece_num">0</strong>件</div>
			<div class="totalMoney">共计: <strong class="total_text">0.00</strong></div>
			<div class="calBtn"><a href="javascript:;">去结算</a></div>
		</div>
	</div>
</section>
</body>

<script type="text/javascript">
function goDelete(cartId){
	if(confirm("确认删除?")){
		$.ajax({//进行提交
			type : "post",//提交方式
			url : "${pageContext.request.contextPath}/deletecart",//提交路径
			async : true,//是否异步
			dataType : 'json',//数据格式（不进行跨越json，跨域使用jsonp），
			data : { //参数
				cartId : cartId,
			},
			success : function(data) {//执行成功后调用的方法
					if(data[0] == 1){
						alert("删除成功");
						window.location.reload();
					}else{
						alert("删除失败");
					}	
					query();
				},
			error : function(err) {//执行失败后的失败信息的显示
				console.log(err);
			}
		});
	} 
 }

function find(){
	window.location.href='http://localhost:8080/jsp/user/findGoods.jsp';
} 
</script>
</html>